$(document).ready(function() {
	$('.act').live('click', function() {
		var type = this.type;
		var value = $(this).attr('value');
		if (type == 'cell') {
			var index = $(this.parentNode.parentNode).attr('data-index');
			index = parseInt(index, 10);
			var id = this.parentNode.parentNode.parentNode.id;
			if (value == 'up') {
				if (index != 0) {
					$("#" + id + " div.item:eq(" + index + ")")
							.insertBefore($("#" + id + " div.item:eq("
									+ (index - 1) + ")"));
				}
			} else {
				var max = $("#" + id + " div.item:last").attr('data-index');
				if (max != 0) {
					$("#" + id + " div.item:eq(" + index + ")")
							.insertAfter($("#" + id + " div.item:eq("
									+ (index + 1) + ")"));
				}
			}
			var count = 0;
			$("#" + id + " div.item").each(function() {
						$(this).attr('data-index', count);
						count++;
					});
		}
		if (type == 'row') {
			var index = $(this.parentNode.parentNode).attr('data-index');
			index = parseInt(index, 10);
			if (value == 'up') {
				$("#row" + index).insertBefore($("#row" + (index - 1)));
			} else {
				$("#row" + index).insertAfter($("#row" + (index + 1)));
			}
			var count = 0;
			$("tr.listitem").each(function() {
						$(this).attr('data-index', count);
						$(this).attr('id', 'row' + count);
						count++;
					});
		}

	});
	
	$('.delte').live('click',function(){
		if(BaseJs.confirm('确定删除？')){
			$($(this)[0].parentNode.parentNode).remove();
		}
	});
});